package com.letu.core.dynamic;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;


/**
 * java类型枚举
 * @author Administrator
 *
 */
public enum FieldType {
    STRING("str", "字符串",String.class,String.class),
    DOUBLE("double", "小数点",Double.class,Double.class),
    DOUBLE_SMALL("double", "小数点",double.class,double.class),
    LONG("long", "小数点",Long.class,Long.class),
    LONG_SMALL("long", "小数点",long.class,long.class),
    INTEGER("int", "整型",Integer.class,Integer.class),
    INT("int", "整型",int.class,int.class),
    DATE("date", "日期",Date.class,Date.class),
    LOCAL_DATE_TIME("localDateTime", "日期", LocalDateTime.class,LocalDateTime.class),
    BIGDECIMAL("bigDecimal", "金额",BigDecimal.class,BigDecimal.class),
    LIST("list", "集合",List.class,List.class),
    ARRAYLIST("arrayList", "集合",ArrayList.class,List.class),
    MAP("map", "map",Map.class,Map.class),
    HASHMAP("hashMap", "map",HashMap.class,Map.class),
    LINKEDHASHMAP("hashMap", "map",LinkedHashMap.class,Map.class),
    HASTSET("hastSet", "集合",HashSet.class,Set.class),
    SET("set", "集合",Set.class,Set.class),

    FLOAT("Float", "小数点",Float.class,Float.class),
    FLOAT_SMALL("float", "小数点",float.class,float.class),

    BYTE("Byte", "byte",Byte.class,Byte.class),
    BYTE_SMALL("byte", "byte",byte.class,byte.class),

    BOOLEAN("Boolean", "小数点",Boolean.class,Boolean.class),
    BOOLEAN_SMALL("boolean", "小数点",boolean.class,boolean.class)
    ;

    /**
     * 标识名
     */
    private String name;
    /**
     * 描述
     */
    private String remark;
    /**
     * 类型
     */
    private Class clazz;

    /**
     * 类型
     */
    private Class targerClazz;
    private FieldType(String name, String remark,Class clazz,Class targerClazz) {
        this.name = name;
        this.remark = remark;
        this.clazz=clazz;
        this.targerClazz = targerClazz;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Class getClazz() {
        return clazz;
    }
    public void setClazz(Class clazz) {
        this.clazz = clazz;
    }

    public Class getTargerClazz() {
        return targerClazz;
    }


    public static FieldType findByField(String className) {
        FieldType[] fieldTypes = FieldType.values();
        for (int i = 0; i < fieldTypes.length; i++) {
            if (fieldTypes[i].clazz.getName().equals(className) ) {
                return fieldTypes[i];
            }
        }
        return null;
    }
}

